package com.mobileduty.pages;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatCheckBox;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.mobileduty.R;

/**
 * 登录界面
 */

public class LoginActivity extends Activity implements View.OnClickListener {
    private Context context = this;
    private ImageView titlebar_back;
    private TextView titlebar_title;
    private ImageView titlebar_other;
    private EditText login_username;
    private EditText login_pwd;
    private Button login_go;
    private AppCompatCheckBox login_record_pwd;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_main);
        initView();
    }

    private void initView() {
        titlebar_back = (ImageView) findViewById(R.id.titlebar_back);
        titlebar_back.setVisibility(View.GONE);
        titlebar_title = (TextView) findViewById(R.id.titlebar_title);
        titlebar_title.setText("登录");
        titlebar_other = (ImageView) findViewById(R.id.titlebar_other);
        titlebar_other.setVisibility(View.GONE);
        login_username = (EditText) findViewById(R.id.login_username);
        login_pwd = (EditText) findViewById(R.id.login_pwd);
        login_go = (Button) findViewById(R.id.login_go);
        login_record_pwd = (AppCompatCheckBox) findViewById(R.id.login_record_pwd);

        login_go.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.login_go:
                startActivity(new Intent(context, MainTabActivity.class));
                finish();
                break;
        }
    }

    private void submit() {
        // validate
        String username = login_username.getText().toString().trim();
        if (TextUtils.isEmpty(username)) {
            Toast.makeText(this, "请输入用户名", Toast.LENGTH_SHORT).show();
            return;
        }

        String pwd = login_pwd.getText().toString().trim();
        if (TextUtils.isEmpty(pwd)) {
            Toast.makeText(this, "请输入用密码", Toast.LENGTH_SHORT).show();
            return;
        }

    }
}
